package shop.up.all.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import shop.up.model.order.OrderInfo;
import shop.up.order.client.OrderFeignClient;

import javax.servlet.http.HttpServletRequest;

/**
 * 支付接口 {@link PaymentController}
 *
 * @author Kevin
 * @date 2022/7/28
 */
@Controller
public class PaymentController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * 支付页
     * @param orderId
     * @return
     */
    @GetMapping("pay.html")
    public String success(Long orderId, Model model) {
        // 远程调用获取订单信息
        OrderInfo orderInfo = orderFeignClient.getOrderInfo(orderId);
        model.addAttribute("orderInfo", orderInfo);
        return "payment/pay";
    }

    /**
     * 支付成功页
     * @return
     */
    @GetMapping("pay/success.html")
    public String success() {
        return "payment/success";
    }

}
